import pytest


# # 用例需用到多个fixture返回的数据时，fixture可以return一个元组，list或者字典，从里边取出要用的数据；
# @pytest.fixture()
# def user():
#     print("获取用户名")
#     user = "zkk"
#     pwd = "123456"
#     return (user, pwd)
#
#
# def test_1(user):
#     # 调用user，返回的结果是元组，所以用以下取值方式
#     u = user[0]
#     p = user[1]
#     print("测试账号 %s, 密码 %s" % (u, p))
#     assert u == "zkk"
#
# if __name__ == '__main__':
#     pytest.main(["-s", "20_longFixture.py"])

#        2、用例同时调用多个fixture的前置操作，每个fixture都返回一个数据
# @pytest.fixture()
# def t_name():
#     print("获取用户名")
#     name = "zkk"
#     return name
#
# @pytest.fixture()
# def t_pwd():
#     print("获取密码")
#     pwd = "123456"
#     return pwd
#
# def test_name(t_name, t_pwd):
#     u = t_name
#     p = t_pwd
#     print("用户名%s,密码是%s" % (u, p))
#     assert u == "zkk"
#
# if __name__ == '__main__':
#     pytest.main(['-s', "20_longFixture.py"])


# 3、fixture与fixture之间互相调用

@pytest.fixture()
def first():
    print("获取用户名")
    name = "zkk"
    return name

@pytest.fixture()
def sencond(first):
    print("账户")
    name = first
    pwd = "123456"
    return (name, pwd)

def test_1(sencond):
    print("用户名%s， 密码%s" % (sencond[0], sencond[1]))

if __name__ == '__main__':
    pytest.main(['-s', "20_longFixture.py"])